<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="redmine,jenkins,sonarqube,checkstyle,pmd," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="前文回顾前文我们讲述自动化生成线的持续开发阶段，并对基于GitFlow的研发流程及应用场景结合之前所讲的工具做了案例演示。本文我们将继续介绍构成持续开发内部循环的重要环节—代码审查及支持工具SonarQube。">
<meta property="og:type" content="article">
<meta property="og:title" content="IT自动化(8)——持续开发中的代码审查SonarQube">
<meta property="og:url" content="http://chrisrc.me/2015/09/17/autoit-sonarqube/index.html">
<meta property="og:site_name" content="山中，山外与俯瞰">
<meta property="og:description" content="前文回顾前文我们讲述自动化生成线的持续开发阶段，并对基于GitFlow的研发流程及应用场景结合之前所讲的工具做了案例演示。本文我们将继续介绍构成持续开发内部循环的重要环节—代码审查及支持工具SonarQube。">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_jenkins_config.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_job1.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_job2.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_job3.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_job4.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_job5.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_result1.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_result2.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_result3.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_result5.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_result4.png">
<meta property="og:image" content="http://chrisrc.me/images/autoit_sonar_redmine_config.png">
<meta property="og:updated_time" content="2016-12-17T07:29:29.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="IT自动化(8)——持续开发中的代码审查SonarQube">
<meta name="twitter:description" content="前文回顾前文我们讲述自动化生成线的持续开发阶段，并对基于GitFlow的研发流程及应用场景结合之前所讲的工具做了案例演示。本文我们将继续介绍构成持续开发内部循环的重要环节—代码审查及支持工具SonarQube。">
<meta name="twitter:image" content="http://chrisrc.me/images/autoit_sonar_jenkins_config.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://chrisrc.me/2015/09/17/autoit-sonarqube/"/>





  <title> IT自动化(8)——持续开发中的代码审查SonarQube | 山中，山外与俯瞰 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">山中，山外与俯瞰</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">一次永不停止的探索之旅</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-dcos">
          <a href="/dcos" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            DC/OS
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="st-search-show-outputs">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'R9GcmhBwxpsAGLNCsquZ','2.0.0');
</script>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://chrisrc.me/2015/09/17/autoit-sonarqube/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="chrisrc">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="山中，山外与俯瞰">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="山中，山外与俯瞰" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                IT自动化(8)——持续开发中的代码审查SonarQube
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2015-09-17T14:24:27+08:00">
                2015-09-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IT自动化/" itemprop="url" rel="index">
                    <span itemprop="name">IT自动化</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <a href="/2015/09/17/autoit-sonarqube/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/09/17/autoit-sonarqube/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="前文回顾"><a href="#前文回顾" class="headerlink" title="前文回顾"></a>前文回顾</h2><p><a href="/2015-09-16/autoit-jenkins-with-gitlab">前文</a>我们讲述自动化生成线的持续开发阶段，并对基于<code>GitFlow</code>的研发流程及应用场景结合之前所讲的<br>工具做了案例演示。本文我们将继续介绍构成持续开发内部循环的重要环节—代码审查及支持工具SonarQube。</p>
<a id="more"></a>
<h2 id="SonarQube简介"><a href="#SonarQube简介" class="headerlink" title="SonarQube简介"></a>SonarQube简介</h2><p><a href="http://www.sonarqube.org/" target="_blank" rel="external">SonarQube</a>是一个开源的代码质量审查与管理平台。它可以对开发过程中的代码进行持续审查，解决开发过程中存在的：1）不遵循代码标准，2）代码中存在<br>潜在的BUG，3）代码文件，类定义，方法定义复杂度过高，导致难以理解，4）大量重复粘帖代码导致质量底下，5）存在循环依赖，耦合度过高等糟糕的设计<br>等等质量问题。</p>
<p>通过提前暴露这些问题，可以提高产品的质量，稳定性，提升团队的协作效率，降低产品持续运营的复杂度。</p>
<h2 id="SonarQube的功能"><a href="#SonarQube的功能" class="headerlink" title="SonarQube的功能"></a>SonarQube的功能</h2><ul>
<li><p>支持20多种语言的代码审查</p>
</li>
<li><p>支持与第三方分析工具如Android Lint，Checkstyle，PMD，Findbugs，Resharper， StyleCop等集成</p>
</li>
<li><p>支持与Intelij IDEA，Eclipse等IDE工具集成</p>
</li>
<li><p>支持聚合视图和生成报表</p>
</li>
<li><p>支持与Jenkins、Jira、Redmine等工具集成</p>
</li>
</ul>
<h2 id="SonarQube的安装使用"><a href="#SonarQube的安装使用" class="headerlink" title="SonarQube的安装使用"></a>SonarQube的安装使用</h2><p>下载SonarQube安装包并解压后，可以直接运行。如果想以系统服务的形式运行SonarQube，请参考<a href="http://docs.sonarqube.org/display/SONAR/Running+SonarQube+as+a+Service+on+Linux" target="_blank" rel="external">Running SonarQube as a Service on Linux</a>。</p>
<h3 id="数据库配置"><a href="#数据库配置" class="headerlink" title="数据库配置"></a>数据库配置</h3><p>SonarQube默认运行时使用H2数据库，在生产环境中需要重新配置。以MySQL为例，首先创建名为<code>sonar</code>的数据库：  </p>
<blockquote>
<p><code>create database sonar default character utf8;</code></p>
</blockquote>
<p>然后，创建名为<code>sonar</code>的用户，并将数据库<code>sonar</code>的操作权限赋予该用户：  </p>
<blockquote>
<p><code>create user sonar identified by &#39;123456&#39;;</code><br><code>grant all privileges on sonar.* to &#39;sonar&#39;@&#39;localhost&#39; identified by &#39;123456&#39;;</code></p>
</blockquote>
<p>数据库表及用户创建完毕后，修改SonarQube的配置文件<code>{INSTALL_HOME}/conf/sonar.properties</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">sonar.jdbc.username=sonar</div><div class="line">sonar.jdbc.password=123456</div><div class="line">sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8&amp;rewriteBatchedStatements=true&amp;useConfigs=maxPerformance</div></pre></td></tr></table></figure>
<h3 id="运行SonarQube"><a href="#运行SonarQube" class="headerlink" title="运行SonarQube"></a>运行SonarQube</h3><p>调用`{INSTALL_HOME}/bin/’目录中特定系统环境的脚本，启动或停止Sonar服务：  </p>
<blockquote>
<p><code>./sonar.sh start</code></p>
<p><code>./sonar.sh stop</code></p>
</blockquote>
<p><strong>提示：</strong> SonarQube启动时默认端口为<code>9000</code>，可通过 <a href="http://127.0.0.1:9000" target="_blank" rel="external">http://127.0.0.1:9000</a> 进行访问，默认用户名：<code>admin</code>，默认密码：<code>admin</code>。</p>
<h2 id="Jenkins与SonarQube集成"><a href="#Jenkins与SonarQube集成" class="headerlink" title="Jenkins与SonarQube集成"></a>Jenkins与SonarQube集成</h2><h3 id="配置SonarQube插件"><a href="#配置SonarQube插件" class="headerlink" title="配置SonarQube插件"></a>配置SonarQube插件</h3><p>按之前介绍Jenkins的文章步骤安装SonarQube插件，安装完成后，进入系统设置界面配置SonarQube服务器信息：  </p>
<p><img src="/images/autoit_sonar_jenkins_config.png" alt="Jenkins Sonar Config"></p>
<h3 id="项目代码审计任务"><a href="#项目代码审计任务" class="headerlink" title="项目代码审计任务"></a>项目代码审计任务</h3><p>我们在Jenkins上构建一个<a href="">greeter-osgi-example</a>项目的审计任务，该任务每天自动执行一次，审计结果会提交到SonarQube服务器。</p>
<p>在Jenkins中新建一个Job，名称为<code>greeter-osgi-example_sonar</code>，选择Job类型为 <em>构建一个Maven项目</em>：<br><img src="/images/autoit_sonar_job1.png" alt="Jenkins Sonar Config"></p>
<p>在源代码管理中配置项目的访问URL并设定编译分支为开发分支<code>*/dev</code>，本例URL采用<code>git</code>协议，优点是不需要访问Gitlab的具体账户，<br>缺点是你必须为Jenkins生成SSH公钥和私钥，并<br>在Gitlab对应项目的<code>Deploy Keys</code>中配置该公钥。关于生成JenkinsSSH公钥的步骤，请参考<a href="/2015-08-17/autoit-jenkins-notes">Jenkins安装注记</a>。</p>
<p><img src="/images/autoit_sonar_job2.png" alt="Jenkins Sonar Job"></p>
<p>在 <strong>构建触发器</strong> 一项中，选择<code>Build periodically</code>，在日程表中填写<code>@Daily</code>，这样任务就会每天定时执行一次。项目负责人和团队成员就可以每天<br>对提交的代码进行质量审查，及时发现问题并纠正。</p>
<p><img src="/images/autoit_sonar_job3.png" alt="Jenkins Sonar Job"></p>
<p>因任务是Maven项目，在<code>Build</code>的目标栏里填写<code>clean package</code>，然后在 <em>构建后操作</em> 列表中选择添加<code>SonarQube</code>，保持默认配置即可。</p>
<p><img src="/images/autoit_sonar_job4.png" alt="Jenkins Sonar Job"></p>
<p>保存任务配置，在任务信息视图即可看到SonarQube的图标链接，任务执行后，可通过此链接直接访问SonarQube服务器。</p>
<p><img src="/images/autoit_sonar_job5.png" alt="Jenkins Sonar Job"></p>
<p>下面是任务执行的输出：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div></pre></td><td class="code"><pre><div class="line">[INFO] [15:41:18.544] -------------  Scan greeter</div><div class="line">[INFO] [15:41:18.545] Load module settings</div><div class="line">[INFO] [15:41:18.586] Base dir: /var/lib/jenkins/jobs/greeter-osgi-example_sonar/workspace</div><div class="line">[INFO] [15:41:18.587] Working dir: /var/lib/jenkins/jobs/greeter-osgi-example_sonar/workspace/target/sonar</div><div class="line">[INFO] [15:41:18.587] Source encoding: UTF-8, default locale: zh_CN</div><div class="line">[INFO] [15:41:18.596] Redmine issues sensor will not run as some parameters are missing.</div><div class="line">[INFO] [15:41:18.598] Sensor Lines Sensor</div><div class="line">[INFO] [15:41:18.598] Sensor Lines Sensor (done) | time=0ms</div><div class="line">[INFO] [15:41:18.598] Sensor InitialOpenIssuesSensor</div><div class="line">[INFO] [15:41:18.601] Sensor InitialOpenIssuesSensor (done) | time=3ms</div><div class="line">[INFO] [15:41:18.601] Sensor ProjectLinksSensor</div><div class="line">[INFO] [15:41:18.604] Sensor ProjectLinksSensor (done) | time=3ms</div><div class="line">[INFO] [15:41:18.604] Sensor VersionEventsSensor</div><div class="line">[INFO] [15:41:18.644] Sensor VersionEventsSensor (done) | time=40ms</div><div class="line">[INFO] [15:41:18.644] Sensor Maven dependencies</div><div class="line">[INFO] [15:41:18.644] Sensor Maven dependencies (done) | time=0ms</div><div class="line">[INFO] [15:41:18.645] Sensor SCM Sensor</div><div class="line">[INFO] [15:41:18.645] Sensor SCM Sensor (done) | time=0ms</div><div class="line">[INFO] [15:41:18.645] Sensor CPD Sensor</div><div class="line">[INFO] [15:41:18.645] Sensor CPD Sensor (done) | time=0ms</div><div class="line">[INFO] [15:41:18.646] No quality gate is configured.</div><div class="line">[INFO] [15:41:18.710] Execute decorators...</div><div class="line">[INFO] [15:41:18.806] Store results in database</div><div class="line">[INFO] [15:41:19.768] Analysis reports generated in 21ms, dir size=1 KB</div><div class="line">[INFO] [15:41:19.778] Analysis reports compressed in 10ms, zip size=4 KB</div><div class="line">[INFO] [15:41:20.330] Analysis reports sent to server in 552ms</div><div class="line">[INFO] [15:41:20.330] ANALYSIS SUCCESSFUL, you can browse http://127.0.0.1:9000/dashboard/index/org.example.greeter:greeter</div><div class="line">[INFO] [15:41:20.330] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">[INFO] Reactor Summary:</div><div class="line">[INFO]</div><div class="line">[INFO] greeter ........................................... SUCCESS [25.177s]</div><div class="line">[INFO] greeter-api ....................................... SKIPPED</div><div class="line">[INFO] greeter-service ................................... SKIPPED</div><div class="line">[INFO] greeter-client .................................... SKIPPED</div><div class="line">[INFO] greeter-feature-service ........................... SKIPPED</div><div class="line">[INFO] greeter-feature-client ............................ SKIPPED</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">[INFO] BUILD SUCCESS</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">[INFO] Total time: 35.346s</div><div class="line">[INFO] Finished at: Tue Sep 22 15:41:20 CST 2015</div><div class="line">[INFO] Final Memory: 27M/581M</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">SonarQube analysis completed: SUCCESS</div><div class="line">Finished: SUCCESS</div></pre></td></tr></table></figure></p>
<h3 id="分析审计结果"><a href="#分析审计结果" class="headerlink" title="分析审计结果"></a>分析审计结果</h3><p>登录SonarQube服务器，我们可以看到项目审计结果:  </p>
<p><img src="/images/autoit_sonar_result1.png" alt="Jenkins Sonar Result"></p>
<p>点击链接进入详细页面，通过此页面我们可以查看项目的统计信息，包括项目代码行数，文件数，代码重复情况，代码复杂度以及代码中存在的<br>问题（阻断，严重，主要，次要，信息）：</p>
<p><img src="/images/autoit_sonar_result2.png" alt="Jenkins Sonar Result"></p>
<p>点击问题链接，即可进入详细的问题列表：</p>
<p><img src="/images/autoit_sonar_result3.png" alt="Jenkins Sonar Result"></p>
<p>点击问题右侧的<img src="/images/autoit_sonar_result5.png" alt="Sonar Problems indicator">图标，可以查看该问题的评估规则。点击<code>More</code>下拉菜单<br>可以将问题发布到Redmine等问题跟踪系统（请参考与Redmine的集成），由开发人员具体解决。</p>
<p><img src="/images/autoit_sonar_result4.png" alt="Jenkins Sonar Result"></p>
<h2 id="SonarQube与Redmine集成"><a href="#SonarQube与Redmine集成" class="headerlink" title="SonarQube与Redmine集成"></a>SonarQube与Redmine集成</h2><p>在<code>greeter</code>项目配置下拉菜单中选择<code>Redmine</code>，配置与Redmine的集成设定。</p>
<p><img src="/images/autoit_sonar_redmine_config.png" alt="Sonar Redmine"></p>
<p><strong>提示：</strong> Redmine的API Key可以通过查询Redmine的数据库表<code>tokens</code>获取。</p>
<h2 id="SonarQube与IDE环境集成"><a href="#SonarQube与IDE环境集成" class="headerlink" title="SonarQube与IDE环境集成"></a>SonarQube与IDE环境集成</h2><p>请参考<a href="/2015-09-02/autoit-sonarqube-eclipse">代码审查工具SonarQube与Eclipse集成</a>。</p>
<h2 id="SonarQube在IT自动化中的作用"><a href="#SonarQube在IT自动化中的作用" class="headerlink" title="SonarQube在IT自动化中的作用"></a>SonarQube在IT自动化中的作用</h2><p>通过过上述介绍，我们通过Jenkins任务，将Gitlab，SonarQube和Redmine整合起来，形成了Gitlab—Jenkins—SonarQube—Redmine的小闭环。</p>
<p>项目团队开发人员提交的代码，在持续审查过程中发现的问题又自动反馈给开发人员，最终确保在代码合并到测试或发布分支之前，<br>一些潜在的问题都已解决。</p>
<h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><ul>
<li>本文构建了代码编写、提交、审查、反馈一系列环节的自动化流程，借助这些工具实现开发过程中的持续审查，可以确保代码的规范，潜在缺陷<br>的提前修正，降低代码后期维护的难度。</li>
<li>持续审查为IT自动化过程中的一个增强环节，可根据项目的实际需要进行配置。</li>
<li>在下一篇文章中，将简单讲述用于需求及缺陷跟踪的Redmine工具。</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/redmine/" rel="tag"># redmine</a>
          
            <a href="/tags/jenkins/" rel="tag"># jenkins</a>
          
            <a href="/tags/sonarqube/" rel="tag"># sonarqube</a>
          
            <a href="/tags/checkstyle/" rel="tag"># checkstyle</a>
          
            <a href="/tags/pmd/" rel="tag"># pmd</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/09/16/autoit-jenkins-with-gitlab/" rel="next" title="IT自动化(7)——持续集成从Gitlab到Jenkins">
                <i class="fa fa-chevron-left"></i> IT自动化(7)——持续集成从Gitlab到Jenkins
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/09/18/linux-deepin/" rel="prev" title="推荐Linux操作系统——Deepin">
                推荐Linux操作系统——Deepin <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/09/17/autoit-sonarqube/"
     data-title="IT自动化(8)——持续开发中的代码审查SonarQube"
     data-content=""
     data-url="http://chrisrc.me/2015/09/17/autoit-sonarqube/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/09/17/autoit-sonarqube/"
           data-title="IT自动化(8)——持续开发中的代码审查SonarQube" data-url="http://chrisrc.me/2015/09/17/autoit-sonarqube/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="chrisrc" />
          <p class="site-author-name" itemprop="name">chrisrc</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">69</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">162</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/christtrc" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/chrisrc" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前文回顾"><span class="nav-number">1.</span> <span class="nav-text">前文回顾</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SonarQube简介"><span class="nav-number">2.</span> <span class="nav-text">SonarQube简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SonarQube的功能"><span class="nav-number">3.</span> <span class="nav-text">SonarQube的功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SonarQube的安装使用"><span class="nav-number">4.</span> <span class="nav-text">SonarQube的安装使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#数据库配置"><span class="nav-number">4.1.</span> <span class="nav-text">数据库配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#运行SonarQube"><span class="nav-number">4.2.</span> <span class="nav-text">运行SonarQube</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Jenkins与SonarQube集成"><span class="nav-number">5.</span> <span class="nav-text">Jenkins与SonarQube集成</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#配置SonarQube插件"><span class="nav-number">5.1.</span> <span class="nav-text">配置SonarQube插件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#项目代码审计任务"><span class="nav-number">5.2.</span> <span class="nav-text">项目代码审计任务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#分析审计结果"><span class="nav-number">5.3.</span> <span class="nav-text">分析审计结果</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SonarQube与Redmine集成"><span class="nav-number">6.</span> <span class="nav-text">SonarQube与Redmine集成</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SonarQube与IDE环境集成"><span class="nav-number">7.</span> <span class="nav-text">SonarQube与IDE环境集成</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SonarQube在IT自动化中的作用"><span class="nav-number">8.</span> <span class="nav-text">SonarQube在IT自动化中的作用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结论"><span class="nav-number">9.</span> <span class="nav-text">结论</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">
     
      <a href="mailto:chrisrc@qq.com">chrisrc</a> 
    
  </span>
  <span class="author"> &nbsp; QQ: 58122705 </span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"chrisrc"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  








  
  

  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
<script>
(function(){
   var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04":"https://jspassport.ssl.qhimg.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04";
   document.write('<script src="' + src + '" id="sozz"><\/script>');
})();
</script>

  


</body>
</html>
